package com.maybach.core.shiro.matcher;


import com.maybach.util.AssertUtil;
import com.maybach.util.Md5Util;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.CredentialsMatcher;

/**
 * Created by houenxun on 15/11/30.
 */
public class MD5CredentialsMatcher implements CredentialsMatcher {
    @Override
    public boolean doCredentialsMatch(AuthenticationToken authenticationToken, AuthenticationInfo authenticationInfo) {
        AssertUtil.notNull(authenticationToken.getPrincipal(), "authenticationToken.getPrincipal()");
        String psw = Md5Util.stringMD5(new String((char[]) authenticationToken.getCredentials()));
        return psw.equals(authenticationInfo.getCredentials());
    }
}
